post_{$field}
Filter HookDescription
Filters the value of a specific post field for display. Only applied to post fields name which is *not* prefixed with `post_`. The dynamic portion of the hook name, `$field`, refers to the post field name. Possible filter names include: - `post_ID` - `post_comment_status` - `post_ping_status` - `post_to_ping` - `post_pinged` - `post_guid` - `post_menu_order` - `post_comment_count`Hook Information
File Location |
wp-includes/post.php
View on GitHub
|
Hook Type | Filter |
Line Number | 3213 |
Hook Parameters
Type | Name | Description |
---|---|---|
mixed
|
$value
|
Value of the unprefixed post field. |
int
|
$post_id
|
Post ID |
string
|
$context
|
Context for how to sanitize the field. Accepts 'raw', 'edit', 'db', 'display', 'attribute', or 'js'. Default 'display'. |
Usage Examples
Basic Usage
<?php
// Hook into post_{$field}
add_filter('post_{$field}', 'my_custom_filter', 10, 3);
function my_custom_filter($value, $post_id, $context) {
// Your custom filtering logic here
return $value;
}
Source Code Context
wp-includes/post.php:3213
- How this hook is used in WordPress core
<?php
3208 * @param int $post_id Post ID
3209 * @param string $context Context for how to sanitize the field.
3210 * Accepts 'raw', 'edit', 'db', 'display',
3211 * 'attribute', or 'js'. Default 'display'.
3212 */
3213 $value = apply_filters( "post_{$field}", $value, $post_id, $context );
3214 }
3215
3216 if ( 'attribute' === $context ) {
3217 $value = esc_attr( $value );
3218 } elseif ( 'js' === $context ) {
PHP Documentation
<?php
/**
* Filters the value of a specific post field for display.
*
* Only applied to post fields name which is *not* prefixed with `post_`.
*
* The dynamic portion of the hook name, `$field`, refers to the post
* field name. Possible filter names include:
*
* - `post_ID`
* - `post_comment_status`
* - `post_ping_status`
* - `post_to_ping`
* - `post_pinged`
* - `post_guid`
* - `post_menu_order`
* - `post_comment_count`
*
* @since 2.3.0
*
* @param mixed $value Value of the unprefixed post field.
* @param int $post_id Post ID
* @param string $context Context for how to sanitize the field.
* Accepts 'raw', 'edit', 'db', 'display',
* 'attribute', or 'js'. Default 'display'.
*/
Quick Info
- Hook Type: Filter
- Parameters: 3
- File: wp-includes/post.php
Related Hooks
Related hooks will be displayed here in future updates.